import React from 'react';
import {Route, withRouter} from 'react-router-dom';
import {Tools} from 'weaver-mobile';

const getLabel = Tools.getLabel;

@withRouter
export default class FileView extends React.Component {
  render() {
    const {location, path} = this.props;
    const {pathname, search} = location
    const paths = pathname.split("/");
    const fileid = paths[paths.length - 1];
    let urlParams = search.slice(search.indexOf('?') + 1);
    return (
      <Route
        key={`${path}-iframe`}
        path={`${path}/iframe`}
        render={() => {
          return (
            <div className="wm-route-layout">
              <iframe src={`/spa/document/index2mobile.jsp?fileid=${fileid}&${urlParams}`} title={getLabel(388748, "查看文件")}
                      frameBorder="0" style={{height: '100%', width: '100%'}}></iframe>
            </div>
          );
        }}
      />
    );
  }
}